home *** CD-ROM | disk | FTP | other *** search
- Path: locutus.rchland.ibm.com!usenet
- From: pstaite@vnet.ibm.com
- Newsgroups: comp.lang.c++
- Subject: Re: Q: Please help me to write to .dat file!
- Date: 9 Jan 1996 22:15:43 GMT
- Organization: IBM OS/2 Device Driver Development Rochester, MN
- Message-ID: <4cupef$nk3@locutus.rchland.ibm.com>
- References: <4csoob$kj@news.tcd.net>
- Reply-To: pstaite@vnet.ibm.com
- NNTP-Posting-Host: warpone.rchland.ibm.com
- X-Newsreader: IBM NewsReader/2 v1.2
-
- In <4csoob$kj@news.tcd.net>, Steve <slavis@PW1.PrairieWeb.Com> writes:
-
- <chopped>
-
- >cout << "Enter the question number:" << endl;
- >cpaQuestion audit;
- >cin >> audit.questionNum;
-
- When you extract a numeric from the input stream it'll stop pulling
- chars from the stream at the next non-numeric. In this case, probably
- leaves the newline in the input buffer. (eg. you type '1' and Enter --
- pulls '1' out, leaves a '\n' in cin)
-
- >if(audit.questionNum > 0 && audit.questionNum <= 100) {
- > cout << "Enter answer:" <<endl;
- > cin.getline(audit.answer, 3);
-
- This getline() sees an immediate newline in the input buffer so it
- returns (empty).
-
- Try adding:
-
- cin.ignore( 100, '\n' );
-
- After reading numerics. This pulls any remaining chars out up to and
- including the newline, or 100 chars.
-
-
- Phil Staite, team OS/2
- internet: pstaite@vnet.ibm.com internal: pstaite@rchland
-
-